package experiment.e05.code;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/10/13 15:29
 * @package experiment.e05.code
 * @description
 * 设计一个Personal类:
 * （1）该类有实例变量（属性）id、name、age、sex；
 * （2）一个无参构造函数和一个有参构造函数;
 * （3）一组用于访问实例变量的set/get方法。
 * 再设计一个测试类TestPersonal,测试该类。
 */

public class Ch01 {

}

class TestPersonal{
    public static void main(String[] args) {
        Personal personal = new Personal();

        // 测试 set
        personal.setId(12);
        personal.setName("黄雄");
        personal.setAge(23);
        personal.setSex('女');

        // 测试 get
        System.out.println(personal.getId());
        System.out.println(personal.getName());
        System.out.println(personal.getAge());
        System.out.println(personal.getSex());
    }
}

class Personal{
    // 实例变量
    private int id;
    private String name;
    private int age;
    private char sex;

    // 构造方法
    public Personal() {
    }

    public Personal(int id, String name, int age, char sex) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    // set && get
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

}
